import { Effect, Reducer } from 'umi';

export type ShopingCartGoods = {};

export type OrderState = {
  uniacid: any;
  store_id: any;
  cashier_id: any;
  order_no: any;
  goodsList: any[];
};

type OrderModalType = {
  namespace: string;
  state: OrderState;
  effects?: {
    pushOrder: Effect;
  };
  reducers?: {
    putUpOrder: Reducer<OrderState>;
  };
};

const Model: OrderModalType = {
  namespace: 'order',
  state: {
    uniacid: '53',
    store_id: '22',
    cashier_id: '33',
    order_no: '202150131421',
    goodsList: [],
  },
  effects: {
    async pushOrder({ action }, { call, put }) {
      console.log(action);
    },
  },
  reducers: {
    putUpOrder(state, action) {
      console.log(action);
      return {
        ...state,
        ...action.data,
      };
    },
  },
};

export default Model;
